﻿using DependencyInjectionSampleOnConsole.ConsoleView.Data.Interfaces;
using DependencyInjectionSampleOnConsole.ConsoleView.Data.Repositories;
using DependencyInjectionSampleOnConsole.ConsoleView.Services;
using Microsoft.Extensions.DependencyInjection;
using System;

namespace DependencyInjectionSampleOnConsole.ConsoleView
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                DependencyInjectionSampleOnConsoleTest();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }

        private static void DependencyInjectionSampleOnConsoleTest()
        {
            var sp = new ServiceCollection()
                .AddScoped<ITestRepository, TestRepository>()
                .AddScoped<ITestService, TestService>()
                .BuildServiceProvider();
            var testService = sp.GetRequiredService<ITestService>();
            testService.TestAsync("SayHello?");
        }
    }
}
